<?php
namespace Common\Controller;
use Think\Controller;
class CommonController extends Controller{
    public function _initialize(){
        
    }
    //图片上传
    public function upload($img,$name=""){
        empty($name)?"Article":$name;
        $upload = new \Think\Upload();// 实例化上传类
        //$upload->maxSize   =  3145728 ;// 设置附件上传大小
        $upload->exts      =  array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
        $upload->savePath  =  '/'.$name.'/'; // 设置附件上传目录
        $info   =   $upload->upload($img);
        if(!$info) {
            // 上传错误提示错误信息
            $this->error($upload->getError());
        }else{
            foreach ( $info as $file ) { // 遍历数组
                $pic = '/' . Uploads . $file ['savepath'] . $file ['savename']; // 加到数据库里边的没有 '/'.Uploads. 所以要加上
            }
        }
        return $pic;
    }
    public function behaviorLog($descrip){
        $data['lb_user_name']=$_SESSION['admin_user_name'];
        $data['lb_luser_id']=$_SESSION['admin_user_id'];
        $data['lb_descrip']=$descrip;
        $data['lb_time']=time();
        M('log_behavior')->add($data);
    }
}